﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows.Data;
using System.Collections;
using System.Windows;

namespace Vision.Core.ActivityComponents.Converters
{
    public class IsEmptyVisibleConverter : IValueConverter
    {
        public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
        {
            bool isReversed = (parameter != null && parameter.ToString().ToLower() == "reverse");

            if (value is IList)
            {
                if (isReversed)
                    return ((value as IList).Count > 0 ? Visibility.Visible : Visibility.Collapsed);
                else
                    return ((value as IList).Count > 0 ? Visibility.Collapsed : Visibility.Visible);
            }

            return Visibility.Collapsed;
        }

        public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
        {
            return value;
        }
    }
}
